package acs.bridge.jreport;

import org.springframework.mail.SimpleMailMessage;

import java.util.Iterator;
import java.util.Properties;

/**
 * acs.jreport
 * User: KuznetsovStV
 * Date: 07.04.13
 * Time: 17:43
 */
public class JReportMailMessage extends SimpleMailMessage {
    public void setTemplate(Properties a_parameters)
    {
        if (a_parameters != null) {
        Iterator it = a_parameters.keySet().iterator();

                   while (it.hasNext()) {
                       String key = (String) it.next();
                       if (key.equals("%templateMessageFrom%") && getFrom() == null)
                           setFrom(a_parameters.getProperty(key));
                       if (key.equals("%templateMessageTo%") && getTo() == null)
                           setTo(a_parameters.getProperty(key));
                       if (key.equals("%templateMessageSubject%") && getSubject() == null)
                           setSubject(a_parameters.getProperty(key));
                       if (key.equals("%templateMessageText%") && getText() == null)
                           setText(a_parameters.getProperty(key));
                   }
        }
    }
}
